<?php

class queris
{
public $queryresult;
public $queryresult2=array();
public $queryresult21=array();
private $query1="select * from commonmenus where menus_lang='lt'";
private $query2;

function __construct(){ 
$result=mysql_query($this->query1); //menu title result
$row = mysql_fetch_row($result);
$this->queryresult=$row[1];  

                                                          
$result=mysql_query("Select * from  meniu_content where  meniutitle='$this->queryresult'"); //meniu isvedimas
$i=0;
while ($row = mysql_fetch_assoc($result)) {
$i++;
$this->queryresult2[$i]=$row["meniunode"];
$this->queryresult21[$i]=$row["id"];
}
}

function addqueris($t){
$result=mysql_query($t);
$row = mysql_fetch_object($result);
$result2=mysql_query("select * from pagecontent where pagetitle='$row->meniunode'");
$row2=mysql_fetch_object($result2);
return $row2;
}

function updatequery1($a,$b,$c,$f,$d){
mysql_real_escape_string($a);
mysql_real_escape_string($b);
mysql_real_escape_string($c);
mysql_real_escape_string($f);
mysql_real_escape_string($d);
mysql_query("UPDATE pagecontent SET pagehtmltitle ='$f',pagehtmlmeta='$a',pagehtmldescription='$b',pagecontent='$c' WHERE id='$d'") or die(mysql_error());  
}
function formdeletor($id,$titler){
if(is_numeric($id)){ 
mysql_query("DELETE FROM pagecontent WHERE id='$id'") or die(mysql_error());
}
mysql_real_escape_string($titler);
mysql_query("DELETE FROM meniu_content WHERE meniunode='$titler'") or die(mysql_error());
}
function forminserter($a,$b,$c,$f,$d,$h){
mysql_query("INSERT INTO meniu_content (meniutitle , meniunode) VALUES('$a', '$b') ") or die(mysql_error());

mysql_real_escape_string($c);
mysql_real_escape_string($d);
mysql_real_escape_string($f);
mysql_real_escape_string($h);

mysql_query("INSERT INTO pagecontent (pagehtmltitle,pagehtmlmeta,pagehtmldescription,pagetitle,pagecontent) VALUES('$c', '$f','$d', '$b','$h') ") or die(mysql_error());  


}
function insertmodulestatus($t,$t1){
mysql_real_escape_string($t);
mysql_real_escape_string($t1);
mysql_query("UPDATE module_config SET status='$t' where module_status='$t1'") or die(mysql_error());  
}

function menureader(){
mysql_query("SET NAMES utf8"); 
$result=mysql_query("Select * from  module_config where  status=1"); //meniu isvedimas
while ($row = mysql_fetch_assoc($result)) {
echo "<a href='index.php?module=$row[module_status]'>".$row['title']."</a><br>";
}
}

function newsinsert($t,$t1){
mysql_real_escape_string($t);
mysql_real_escape_string($t1);
if($t!=null && $t1!=null){
mysql_query("INSERT INTO news (titlas,textas,data) VALUES('$t', '$t1',NOW())") or die(mysql_error());
}
}
function newwsupdate($t1,$t2,$t3){
mysql_real_escape_string($t1);
mysql_real_escape_string($t2);  
echo mysql_real_escape_string($t3);  
mysql_query("UPDATE news SET titlas ='$t1',textas='$t2' where id='$t3'") or die(mysql_error());  
}

function deletenews($t1){
mysql_real_escape_string($t1);
mysql_query("DELETE FROM news WHERE id='$t1'") or die(mysql_error());
}
function deletequestbook($t1){
mysql_real_escape_string($t1);
mysql_query("DELETE FROM questbokas WHERE id='$t1'") or die(mysql_error());
}

}
?>